home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / PROGS / TEXFONT / TexFont.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  1.7 KB  |  94 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1997. */
  3.  
  4. /* This program is freely distributable without licensing fees  and is
  5.    provided without guarantee or warrantee expressed or  implied. This
  6.    program is -not- in the public domain. */
  7.  
  8. #ifndef __TEXFONT_H__
  9. #define __TEXFONT_H__
  10.  
  11. #include <GL/gl.h>
  12.  
  13. #define TXF_FORMAT_BYTE        0
  14. #define TXF_FORMAT_BITMAP    1
  15.  
  16. typedef struct {
  17.   unsigned short c;       /* Potentially support 16-bit glyphs. */
  18.   unsigned char width;
  19.   unsigned char height;
  20.   signed char xoffset;
  21.   signed char yoffset;
  22.   signed char advance;
  23.   char dummy;           /* Space holder for alignment reasons. */
  24.   short x;
  25.   short y;
  26. } TexGlyphInfo;
  27.  
  28. typedef struct {
  29.   GLfloat t0[2];
  30.   GLshort v0[2];
  31.   GLfloat t1[2];
  32.   GLshort v1[2];
  33.   GLfloat t2[2];
  34.   GLshort v2[2];
  35.   GLfloat t3[2];
  36.   GLshort v3[2];
  37.   GLfloat advance;
  38. } TexGlyphVertexInfo;
  39.  
  40. typedef struct {
  41.   GLuint texobj;
  42.   int tex_width;
  43.   int tex_height;
  44.   int max_ascent;
  45.   int max_descent;
  46.   int num_glyphs;
  47.   int min_glyph;
  48.   int range;
  49.   unsigned char *teximage;
  50.   TexGlyphInfo *tgi;
  51.   TexGlyphVertexInfo *tgvi;
  52.   TexGlyphVertexInfo **lut;
  53. } TexFont;
  54.  
  55. extern char *txfErrorString(void);
  56.  
  57. extern TexFont *txfLoadFont(
  58.   char *filename);
  59.  
  60. extern void txfUnloadFont(
  61.   TexFont * txf);
  62.  
  63. extern GLuint txfEstablishTexture(
  64.   TexFont * txf,
  65.   GLuint texobj,
  66.   GLboolean setupMipmaps);
  67.  
  68. extern void txfBindFontTexture(
  69.   TexFont * txf);
  70.  
  71. extern void txfGetStringMetrics(
  72.   TexFont * txf,
  73.   char *string,
  74.   int len,
  75.   int *width,
  76.   int *max_ascent,
  77.   int *max_descent);
  78.  
  79. extern void txfRenderGlyph(
  80.   TexFont * txf,
  81.   int c);
  82.  
  83. extern void txfRenderString(
  84.   TexFont * txf,
  85.   char *string,
  86.   int len);
  87.  
  88. extern void txfRenderFancyString(
  89.   TexFont * txf,
  90.   char *string,
  91.   int len);
  92.  
  93. #endif /* __TEXFONT_H__ */
  94.